//
//  WarnSettingViewController.m
//  Rail
//
//  Created by hychen on 2018/2/27.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "WarnSettingViewController.h"

@interface WarnSettingViewController ()

@end

@implementation WarnSettingViewController

/*
 
 声音键开启时
 
 1、想要既有声音和震动，_notification.soundName需要设为非空值。
 
 2、想要自定义声音，_notification.soundName需要设为工程中某个文件的名字（带后缀）。
 
 3、想要既没声音也没震动，_notification.soundName=nil;
 
 4、想要有震动没声音，_notification.soundName需要设为工程中某个没有声音的音频文件。
 
 声音键关闭时
 
 1、想要震动，_notification.soundName需要设为非空值。
 
 2、想无震动，_notification.soundName=nil;
 
 */

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationItem addSimpleTitleView:@"报警设置"];
    
    [self.navigationItem addRightItem:self title:@"巡线拍照" selector:@selector(gotoLineTakePhotoVc)];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)czh_setGroup
{
    [super czh_setGroup];
    
    BMWeakSelf
    CZHSwitchItem *set1 = [CZHSwitchItem itemWithImageName:nil title:@"报警通知" canClick:YES haveLine:YES];
    set1.isOn = [UserDefaults_bb boolForKey:Key_WarnNotification_Open];
    CZHSettingFrameModel *set1Model = [[CZHSettingFrameModel alloc] init];
    set1Model.item = set1;
    
    CZHSwitchItem *set2 = [CZHSwitchItem itemWithImageName:nil title:@"声音" canClick:YES haveLine:YES];
    set2.isOn = [UserDefaults_bb boolForKey:Key_WarnNotification_Voice];
    CZHSettingFrameModel *set2Model = [[CZHSettingFrameModel alloc] init];
    set2Model.item = set2;
    
    CZHSwitchItem *set3 = [CZHSwitchItem itemWithImageName:nil title:@"震动" canClick:YES haveLine:YES];
    set3.isOn = [UserDefaults_bb boolForKey:Key_WarnNotification_Shake];
    CZHSettingFrameModel *set3Model = [[CZHSettingFrameModel alloc] init];
    set3Model.item = set3;
    
    set1.switchBlock = ^(CZHSwitchItem *item, NSIndexPath *indexPath, BOOL isOn) {
        //WIFI网络自动下载更新包
        [UserDefaults_bb setBool:isOn forKey:Key_WarnNotification_Open];
        item.isOn = isOn;
        set1Model.item = item;
        [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
    };
    
    set2.switchBlock = ^(CZHSwitchItem *item, NSIndexPath *indexPath, BOOL isOn) {
        [UserDefaults_bb setBool:isOn forKey:Key_WarnNotification_Voice];
        item.isOn = isOn;
        set2Model.item = item;
        [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
    };
    
    set3.switchBlock = ^(CZHSwitchItem *item, NSIndexPath *indexPath, BOOL isOn) {
        [UserDefaults_bb setBool:isOn forKey:Key_WarnNotification_Shake];
        item.isOn = isOn;
        set3Model.item = item;
        [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
    };
    
    CZHSectionItem *sectionZero = [[CZHSectionItem alloc] init];
    sectionZero.items = @[set1Model,set2Model,set3Model];
    [self.sectionGroups addObject:sectionZero];
    
}

- (void)gotoLineTakePhotoVc {
    
}


@end
